from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView
from apps.goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory
from apps.meiduo_admin.serializers.channels import GoodsChannelSerializer, GoodsChannelsSimpleSerializer, \
    GoodsCategorySimpleSerializer
from apps.meiduo_admin.utils.pagination import MeiduoPagination

#商品管理  频道管理 频道的增删改查
class GoodsChannelsViewSet(ModelViewSet):
    queryset = GoodsChannel.objects.all().order_by('-id')
    serializer_class = GoodsChannelSerializer
    pagination_class = MeiduoPagination
#商品管理  频道管理 频道组查询
class GoodsChannelsSimpleAPIView(ListAPIView):
    queryset = GoodsChannelGroup.objects.all()
    serializer_class = GoodsChannelsSimpleSerializer

# 商品管理  频道管理  一级分类查询
class GoodsCategorySimleView(ListAPIView):
    queryset = GoodsCategory.objects.filter(parent__isnull=True)
    serializer_class = GoodsCategorySimpleSerializer